<template>
  <div class="listTemplate">
    <mu-appbar color="primary" class="lan-header">
      <mu-button icon slot="left" v-close>
        <i class="iconfont angle-left iconangle-left "></i>
        <span class="lan-header-back">返回</span>
      </mu-button>
      整改通知单
      <mu-button icon slot="right" @click="searchcontroll = true">
        <i class="iconfont iconshaixuan4"></i>
      </mu-button>
    </mu-appbar>
    <section class="t-body">
      <inspection_record_card2 :state="true"  v-bind:data='data' @fetch="fetch"></inspection_record_card2>

    </section>
    <!-- 筛选 -->
    <mu-dialog
      width="100%"
      transition="slide-right"
      fullscreen
      :open.sync="searchcontroll"
      class="lan-dialog"
    >
      <mu-appbar color="primary" class="lan-header">
        <mu-button icon slot="left" @click="searchcontroll = false">
          <i class="iconfont angle-left iconangle-left"></i>
          <span class="lan-header-back">返回</span>
        </mu-button>筛选条件
        <mu-button icon slot="right" @click="clearSearch">
          <span class="text">清空</span>
        </mu-button>
      </mu-appbar>
      <!-- <mu-bottom-sheet :open.sync="searchcontroll"> -->
      <mu-list class="lan-dialog-body no-padding bg-default">
        <mu-form :model="form" class="mu-lan-form" :label-position="'left'" label-width="25%">
          <!-- <mu-form-item label="开始时间">
            <mu-date-input
              v-model="form.startTime"
              placeholder="请选择"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD HH:mm:ss"
              container="bottomSheet"
              label-float
            ></mu-date-input>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <mu-form-item label="结束时间">
            <mu-date-input
              v-model="form.endTime"
              placeholder="请选择"
              container="bottomSheet"
              label-float
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD HH:mm:ss"
            ></mu-date-input>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item> -->
          <mu-form-item label="项目名称">
            <mu-select
              v-model="form.orgId"
              placeholder="请选择"
              popover-class="lan-popover-select"
            >
              <mu-option
                v-for="(list,index) in projectList"
                :key="index"
                :label="list.projectName"
                :value="list.projectId"
              ></mu-option>
            </mu-select>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          
          
        </mu-form>
        <mu-list-item class="lan-dialog-sumit lan-block-btn-line">
          <mu-button full-width color="primary" class="lan-block-btn" @click="search">确认</mu-button>
        </mu-list-item>
      </mu-list>
    </mu-dialog>
  </div>
</template>

<script>
  import inspection_record_card2 from '../task/components/InspectionRecordCards'
  export default {
    name: 'mainPage',
    components:{
      inspection_record_card2
    },
    data () {
      return {

        data:[],
        pageSize: 10,
        pageNo: 0,
        totalPage:1,
        projectList:[],
        searchcontroll:false,
        form:{orgId:''}
      }
    },
    mounted () {
      this.fetch();
    },
    async created () {
      console.log(this.$A.GUP())
      this.projectList = await this.$A.comData("projectList");
    },
    methods: {
      clearSearch(){
        this.form.orgId = ''
      },
      search() {
      this.pageSize = 10;
      this.pageNo = 0;
      this.totalPage = 1;
      this.data = [];
      this.searchcontroll = false;
      this.fetch();
    },
      fetch () {
        console.log(this.pageNo, this.totalPage);
        if (this.pageNo >= this.totalPage) {
          // this.$closeLoading();
          return false
        };
        this.pageNo += 1;
        let params = {
          orgId: this.form.orgId || this.$A.GS("orgInfo")["orgId"],
          type: this.$A.GS("orgInfo")["type"],
          current:	this.pageNo,//是	int		当前页
          size:this.pageSize,//是	int		当前页大小
          // startTime	:,//否	string		开始时间
          // endTime	:,//否	string		结束时间
          // typeId	:,//否	string		检查类型
          // problemLevel:,	//否	string		0一般 1较大 2重大问题
        };
        this.$A.Go('get', '/safety/checkRect/list', params).then((success) => {
          if (success.code == 200) {
            let datas = success.body.rows;
            this.data = this.data.concat(datas);
            let total = success.body.page.rows|| '0';
            this.totalPage = Math.ceil(total /this.pageSize);
          }
        })
      },
      // problemDetail (val) {
      //   this.$router.push(
      //     {
      //       path: '/accountDetaildf',
      //       query: {
      //         info: val.problemId,
      //       }
      //     });
      // },
    },
  }
</script>
<style lang="scss" scoped>
  .listTemplate {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    .t-body {
      flex: 1;
      overflow: auto;
      padding: 0.1rem 0;
    }
  }
</style>
<style lang="scss">
  .t-close {
    .mu-button-wrapper {
      padding: 0 !important;
    }
  }
</style>
